package com.le.tester.javaThink.fourth.concurrency;

/**
 * createTime：2021/11/12 11:11
 * description：互斥中被阻塞
 */
public class MultiLock {
    //synchronized在休眠的时候不会释放锁，不能被中断
    public synchronized void f1(int count) {
        if (count-- > 0) {
            System.out.println("f1() calling f2() with count " + count);
            f2(count);
        }

    }

    private synchronized void f2(int count) {
        if (count-- > 0) {
            System.out.println("f2() calling f1() with count " + count);
            f1(count);
        }
    }

    public static void main(String[] args) {
        final MultiLock multiLock = new MultiLock();
        new Thread(() -> multiLock.f1(10)).start();
    }
}
